const filterList = val => {
  if (val && typeof val === 'object' && typeof val.length !== 'undefined') {
    return val
      .filter(r => {
        return JSON.stringify(r) !== '{}'
      })
      .slice()
  } else {
    return val
  }
}
export default {
  data() {
    return {
      val: null,
      rowData: null
    }
  },
  props: {
    value: [Object, String, Number, Array, Function, Boolean],
    el: Object,
    config: Object,
    form: Object,
    dataKey: String,
    readOnly: Boolean,
    right: [String, Object]
  },
  watch: {
    val: {
      deep: true,
      handler(val, old) {
        const v = filterList(val)
        const o = filterList(old)
        if ((val && typeof val !== 'object') || (val && typeof val === 'object' && !!val.length)) {
          this.$nextTick(() => {
            this.form && this.form.valiDates(this.dataKey)
          })
        }
        this.$emit('update:value', val)
        this.$emit('change', v, o, this.rowData)
      }
    },
    value(val) {
      this.val = val
    }
  },
  methods: {
    clear() {
      this.val = ''
    },
    getValue() {
      return this.returnValue
    },
    setValue(val) {
      console.log(111111111111111111111111111, this.val)
      this.val = val
    }
  }
}
